package com.zyz.K_集合.Collections.练习;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author: vick
 * @Date: 2025/3/31
 * @Description:
 * @version: 1.0
 */
public class Test {
    public static void main(String[] args) {

        ArrayList<PokerCard> pokerCards = new ArrayList<>();
        String[] suits = {"方块","梅花", "红桃","黑桃"};
        String[] ranks = { "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K","A", "2"};
        //生成54张牌
        for (String suit : suits) {
            for (String rank : ranks) {
                pokerCards.add(new PokerCard(suit, rank));
            }
        }
        pokerCards.add(new PokerCard("","小王"));
        pokerCards.add(new PokerCard("","大王"));


        //洗牌
        Collections.shuffle(pokerCards);
        System.out.println(pokerCards);

        //发牌
        ArrayList tomCards = new ArrayList();
        ArrayList jerryCards = new ArrayList();
        ArrayList vickCards = new ArrayList();
        ArrayList lastCards = new ArrayList();
        for (int i = 0; i < pokerCards.size(); i++) {
            if (i >= pokerCards.size() - 3) { //最后3张底牌
                lastCards.add(pokerCards.get(i));
            } else if (i % 3 == 0) {
                tomCards.add(pokerCards.get(i));
            }else if (i % 3 == 1) {
                jerryCards.add(pokerCards.get(i));
            }else {
                vickCards.add(pokerCards.get(i));
            }
        }

        Collections.sort(tomCards);
        Collections.sort(jerryCards);
        Collections.sort(vickCards);
        Collections.sort(lastCards);

        System.out.println(tomCards);
        System.out.println(jerryCards);
        System.out.println(vickCards);
        System.out.println(lastCards);
    }
}
